/*
 *  Copyright (C) 2010:
 *                 Buzzanca Marco <marco.bzn@gmail.com>
 *         Monaco Davide Giuseppe <black.ralkass@gmail.com>
 *              Petralia Veronica <veronicapetralia@gmail.com>
 *
 * This file is part of DS2011BMP
 *
 * DS2011BMP is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * DS2011BMP is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *
 *
 * NOTE: this file should not be included directly,
 *       Include workerdescriptor.h instead.
 */

/**
 * @file workerdescriptor.cpp
 * @author Marco Buzzanca
 *
 * This file contains WorkerDescriptor class declaration and implementation.
 */

#include <boost/cstdint.hpp>
#include <string>
#include "address.h"
#include "worker.h"

/**
 * WorkerDescriptor
 *
 * Simple data class defining worker nodes' attributes.
 */
class WorkerDescriptor
{
private:
    /**
      * @brief Worker address.
      */
    Address _addr;

    /**
      * @brief Worker status.
      */
    WorkerStatus _status;

public:
    /**
      * @brief Default constructor.
      */
    inline WorkerDescriptor() { }

    /**
      * @brief Specifies address and status.
      */
    inline WorkerDescriptor(const Address& addr,
                            const WorkerStatus& status = Free)
    : _addr(addr), _status(status) { }

    /**
      * @brief Specifies address using provided IP and port and status.
      */
    inline WorkerDescriptor(const std::string& IP, boost::uint16_t port,
                            const WorkerStatus& status = Free)
    : _addr(IP, port), _status(status) { }

    /**
      * @brief Gets worker's address.
      */
    inline const Address& getAddress() const
    { return _addr; }

    /**
      * @brief Sets worker's address.
      */
    inline void setAddress(const Address& addr)
    { _addr = addr; }

    /**
      * @brief Sets worker's address using provided IP and port.
      */
    inline void setAddress(const std::string& IP, boost::uint16_t port)
    { _addr = Address(IP, port); }

    /**
      * @brief Gets worker's status.
      */
    inline const WorkerStatus& getStatus() const
    { return _status; }

    /**
      * @brief Sets worker's status.
      */
    inline void setStatus(const WorkerStatus& status)
    { _status = status; }

};
